function showTitle(text, event, width){
    var tooltip = document.getElementById('tooltip');

	//在页面有滚动条的情况下，原来的处理会出现Bug
 	var top = event.clientY;
 	var left = event.clientX;
 	if (document.documentElement && (document.documentElement.scrollTop||document.documentElement.scrollLeft)){
		top = top + document.documentElement.scrollTop;
		left = left + document.documentElement.scrollLeft;
	} else {
		top = top + document.body.scrollTop;
		left = left + document.body.scrollLeft;
	}

    tooltip.style.top = top +5 + "px";
    tooltip.style.left = left +5 + "px";
    tooltip.style.pointerEvents="none";

    var tooltipcontent = document.getElementById('tooltipcontent');
    tooltipcontent.innerHTML = text;
    tooltipcontent.style.width = width + "px";
}

function hideTitle(){
    var tooltip = document.getElementById('tooltip');
    tooltip.style.top = "-100000px";
    var tooltipcontent = document.getElementById('tooltipcontent');
    tooltipcontent.innerHTML = '';
}

/**
 * 页面载入完成后注册要执行的函数
 * @param {Object} func
 */
//function addOnLoad(func) { 
//  var oldonload = window.onload; 
//  if (typeof window.onload != 'function') { 
//    window.onload = func; 
//  } else {   
//    window.onload = function() { 
//      oldonload(); 
//      func(); 
//    } 
//  } 
//}

/**
 * 报表初始化
 */
//function initialize(){
//	initSheets();
//
//	//修正ie6（重设z-index使当报表很小的时候，分割线不出现）
//	var separatorLine =  document.getElementById("tablist_line");
//	if(separatorLine){
//		separatorLine.style.zIndex = "5";
//	}
//  
//    //填报表初始化
//    if (typeof InputReport != "undefined") {
//        InputReport.getInstance().init();
//    }
//}

//if(typeof dojo == "undefined"){
//	addOnLoad(initialize);
//}else {
//	dojo.addOnLoad(initialize);
//}


/**
 * 普通报表对象
 */
var NeuReport = {
    Id: "reportContent",
 	TYPE_REPORT : 0,
	TYPE_QUERY : 1,
	TYPE_BACKFILL : 2,
    _sheets: [],
    _currentSheet: null,
	_reportId: null,
	_type:null,
	//在initialize中设置domNode
	domNode: null,
    /**
     * 初始化sheet
     * @param {Object} id sheet的id
     */
    initSheet: function(id){
        var sheetDomNode = document.getElementById(id);
		var sheet = new Sheet(sheetDomNode);
        sheet.tabHeader = document.getElementById(id + "_header");
        this._sheets.push(sheet);
    },
    /**
     * 报表初始化
     */
	initialize : function(){
		initSheets();
		setReportType();
        //修正ie6（重设z-index使当报表很小的时候，分割线不出现）
//        var separatorLine = document.getElementById("tablist_line");
//        if (separatorLine) {
//            separatorLine.style.zIndex = "5";
//        }
        
        //填报表初始化
        if (typeof InputReport != "undefined") {
            InputReport.getInstance().init();
        }
		
		this.domNode = document.getElementById("reportContent");
	},
	
    /**
     * 报表载入完成后注册要执行的函数
     * @param {Object} func
     */
	addOnLoad: function(func){
		if (typeof dojo != "undefined") {
			dojo.addOnLoad(func);
		} else {           
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function(){
                    oldonload();
                    func();
                }
            }
		}
	},
	
    /**
     * 获得报表的所有sheet
     */
    getSheets: function(){
        return this._sheets;
    },
    
    /**
     * 获取当前sheet
     */
    getCurrentSheet: function(){
        return this._currentSheet;
    },
    
    /**
     * 设置当前sheet
     * @param {Object} sheet
     */
    setCurrentSheet: function(sheet){
        this._currentSheet = sheet;
    },
	/**
	 * 获得报表id
	 */
	getReportId: function(){
		if(!this._reportId){
			 var inputNode = document.getElementsByName("reportId")[0];
             this._reportId = inputNode.value;
		}
		return this._reportId;
	},
	/**
	 * 获得报表缓存id
	 */
	getCacheId: function(){
		if(!this._cacheId){
			 var inputNode = document.getElementsByName("cachedId")[0];
             this._cacheId = !inputNode?"":inputNode.value;
		}
		return this._cacheId;
	},
	/**
	 * 设置报表的类型
	 * @param {int} type
	 */
	setType: function(type){
		this._type = type;
	},  
	/**
	 * 获得报表类型
	 */
	getType: function(){
		return this._type;
	}
}

/**
 * sheet之间切换
 */
function tab(index, event){
    if (typeof InputReport != "undefined") {//如果是填报表
        InputReport.getInstance().getCellSelector().style.display = "none";
    }
    
    var clickedSheet = NeuReport.getSheets()[index];
    var currentSheet = NeuReport.getCurrentSheet();
    
    if (currentSheet == clickedSheet) {
        return;
    }
    else {//修改class名字，来处理sheet的显示
//        dojo.attr(clickedSheet, "class", "URSheet selectedSheet");
//        dojo.attr(clickedSheet.tabHeader, "class", "tab tabSelected");
        
                clickedSheet.domNode.className = "URSheet selectedSheet";
                clickedSheet.tabHeader.className = "tab_element tab_element_active";
        
//        dojo.attr(currentSheet, "class", "URSheet unSelectedSheet");
//        dojo.attr(currentSheet.tabHeader, "class", "tab tabUnselected");
        
                currentSheet.domNode.className = "URSheet unSelectedSheet";
                currentSheet.tabHeader.className = "tab_element tab_element_inactive";

        NeuReport.setCurrentSheet(clickedSheet);
        
        //以下为设置多布局时切换布局，由于布局大小不一样导致出现的滚动条
//        var pTar = window.frameElement;
////        alert("1:"+pTar.id+" 2: "+window.name);
//        	if(pTar.id =="ReportShowQueryFrame"){   		
//          	if (pTar && !window.opera) {
//			pTar.style.display = "block"
//			if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
//				pTar.height = pTar.contentDocument.body.offsetHeight
//						+ 12;
//			} else if (pTar.Document && pTar.Document.body.scrollHeight) {
//
//				pTar.height = pTar.Document.body.scrollHeight;
//				}
//        	}
//		}
        var pTar = window.frameElement;
        if(pTar && pTar.id =="ReportShowQueryFrame"){   
      
//			var subWeb=document.frames?document.frames["ReportShowQueryFrame"].document:pTar.contentDocument;    
		  	if (pTar && !window.opera){
//		  		pTar.style.display = "block";
		    	if (pTar.contentDocument && pTar.contentDocument.body.parentNode.offsetHeight){
		      		pTar.height = pTar.contentDocument.body.scrollHeight + "px";
//		      		pTar.width = pTar.contentDocument.documentElement.scrollWidth + "px"; 
		    	}else if (pTar.Document && pTar.Document.body.scrollHeight){
		      		pTar.height = pTar.Document.body.scrollHeight + "px";
//		      		pTar.width = document.documentElement.scrollWidth + "px";
		    	}
		  	}
        }
    }
}

function tab2(index, event){
    if (typeof InputReport != "undefined") {//如果是填报表
        InputReport.getInstance().getCellSelector().style.display = "none";
    }
    
    var clickedSheet = NeuReport.getSheets()[index];
    var currentSheet = NeuReport.getCurrentSheet();
    
    if (currentSheet == clickedSheet) {
        return;
    } else if (!!clickedSheet.tabHeader.className && clickedSheet.tabHeader.className.indexOf("tab_element_customer") != -1){
//      dojo.attr(clickedSheet, "class", "URSheet selectedSheet");
//      dojo.attr(clickedSheet.tabHeader, "class", "tab tabSelected");
      
              clickedSheet.domNode.className = "URSheet selectedSheet";
              clickedSheet.tabHeader.className = "tab_element_customer tab_element_active_customer";
      
//      dojo.attr(currentSheet, "class", "URSheet unSelectedSheet");
//      dojo.attr(currentSheet.tabHeader, "class", "tab tabUnselected");
      
              currentSheet.domNode.className = "URSheet unSelectedSheet";
              currentSheet.tabHeader.className = "tab_element_customer tab_element_inactive_customer";

      NeuReport.setCurrentSheet(clickedSheet);
    } else {//修改class名字，来处理sheet的显示
//        dojo.attr(clickedSheet, "class", "URSheet selectedSheet");
//        dojo.attr(clickedSheet.tabHeader, "class", "tab tabSelected");
        
                clickedSheet.domNode.className = "URSheet selectedSheet";
                clickedSheet.tabHeader.className = "tab_element_default tab_element_active_default";
        
//        dojo.attr(currentSheet, "class", "URSheet unSelectedSheet");
//        dojo.attr(currentSheet.tabHeader, "class", "tab tabUnselected");
        
                currentSheet.domNode.className = "URSheet unSelectedSheet";
                currentSheet.tabHeader.className = "tab_element_default tab_element_inactive_default";

        NeuReport.setCurrentSheet(clickedSheet);
    }
        //以下为设置多布局时切换布局，由于布局大小不一样导致出现的滚动条
//        var pTar = window.frameElement;
////        alert("1:"+pTar.id+" 2: "+window.name);
//        	if(pTar.id =="ReportShowQueryFrame"){   		
//          	if (pTar && !window.opera) {
//			pTar.style.display = "block"
//			if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
//				pTar.height = pTar.contentDocument.body.offsetHeight
//						+ 12;
//			} else if (pTar.Document && pTar.Document.body.scrollHeight) {
//
//				pTar.height = pTar.Document.body.scrollHeight;
//				}
//        	}
//		}
        var pTar = window.frameElement;
        if(pTar && pTar.id =="ReportShowQueryFrame"){   
      
//			var subWeb=document.frames?document.frames["ReportShowQueryFrame"].document:pTar.contentDocument;    
		  	if (pTar && !window.opera){
//		  		pTar.style.display = "block";
		    	if (pTar.contentDocument && pTar.contentDocument.body.parentNode.offsetHeight){
		      		pTar.height = pTar.contentDocument.body.scrollHeight + "px";
//		      		pTar.width = pTar.contentDocument.documentElement.scrollWidth + "px"; 
		    	}else if (pTar.Document && pTar.Document.body.scrollHeight){
		      		pTar.height = pTar.Document.body.scrollHeight + "px";
//		      		pTar.width = document.documentElement.scrollWidth + "px";
		    	}
		  	}
        }
}

/**
 * 对应报表中的每一个sheet
 * 
 * @param {Object}
 *            node
 */
function Sheet(node){
    this.id = node.id;
    this.domNode = node;
//    this.modifiableCells = [];
}
Sheet.prototype.getTable = function(){
	var tableNode = this.domNode.getElementsByTagName("table")[0];
	var table = new Table(tableNode);
	return table;
}
Sheet.prototype.getTableRow=function(i){
	var table = this.getTable();
	var rowNode = table.domNode.rows[i];
	var row = new TableRow(rowNode);
	return row;
};
Sheet.prototype.getTableCell=function(i,j){
	var row = this.getTableRow(i);
	var tableCell = row.getTableCell(j);
	return tableCell;
}
Sheet.prototype.getRowCount=function(){
	return this.getTable().domNode.rows.length-1;
}
Sheet.prototype.getColumnCount=function(){
	return this.getTableRow(0).domNode.cells.length;
}

function Table(node){
	this.id = node.id;
	this.domNode = node;
}
Table.prototype.addStyle=function(styleName,styleValue){
	if(this.domNode==null){
		return;
	}
	eval("this.domNode.style."+styleName+"='"+styleValue+"'");
}
Table.prototype.setStyle=function(cssString){
	if(this.domNode==null){
		return;
	}
	if(this.domNode.getAttribute("style")=="[object]"){
		this.domNode.getAttribute("style").setAttribute("cssText", cssString);
	}
	this.domNode.setAttribute("style",cssString);
}

function TableRow(domNode){
	this.domNode = domNode;
	if(this.domNode!=null){
		this.id = this.domNode.id;
	}
}
TableRow.prototype.getTableCell=function(j){
	var cellNode = this.domNode.cells[j-1];
	var tableCell = new TableCell(cellNode);
	return tableCell;
}
TableRow.prototype.addStyle = Table.prototype.addStyle;
TableRow.prototype.setStyle = Table.prototype.setStyle;
TableRow.prototype.getCellCount=function(){
	return this.domNode.cells.length;
}


function TableCell(domNode){
	this.domNode = domNode;
	if(this.domNode!=null){
		if(this.domNode.firstChild!=null){
			this.value = this.domNode.firstChild.data;
		}
		this.id = this.domNode.id;
	}
}
TableCell.prototype.getValue = function(){
	return this.value;
}
TableCell.prototype.setValue = function(value){
	if(this.domNode.firstChild!=null){
		this.domNode.firstChild.data = value;
	}else{
		this.domNode.appendChild(document.createTextNode(value));
	}
	this.domNode.value=value;
	this.domNode.setAttribute("value",value);
}
TableCell.prototype.addStyle = Table.prototype.addStyle;
TableCell.prototype.setStyle = Table.prototype.setStyle;


//报表载入完成后进行初始化
NeuReport.addOnLoad(function(){
	NeuReport.initialize();
	//ProgressBar.stop(this.document);
	
});
/**
 * 设置修改的单元格,存在
 * @param {Object} id
 * @param {Object} value
 */
//Sheet.prototype.setChangedCell = function(id, value){
//    var isAdded = true;
//    for (var i = 0, end = this.changed.length; i < end; i++) {
//        var cell = this.changed[i];
//        if (cell.id == id) {
//            cell.value = value;
//            isAdded = false;
//            break;
//        }
//    }
//    
//    if (isAdded) {
//        this.changed.push({
//            id: id,
//            value: value
//        });
//    }
//}


/**
 * 钻取功能的实现，如果是下钻则传入三个参数，如果是上卷则传入二个参数
 */
function olap(dhName,currentLevel,currentLevelValue){
	if((typeof isPreview !='undefined')&&isPreview==true){
		alert(REPORTCONSTANTS.report_ReleasedReportCanDrill);
		return;
	}
	var param = document.getElementById('UniEAP_Report_olapcontext');
	var paramValue = param.value;
//	var paramValue = "{olapcontext:[{name:'地域维',currentLevel:3,conditionValues:['中国','东北']},"+
//	             "{name:'分类维',currentLevel:2,conditionValues:['食品']}]}";
//	var paramObj = eval(paramValue);
	var paramObj = eval("("+paramValue+")")['olapcontext'];
	if(paramObj == null){
		paramObj = new Array();
		var dh = {name:dhName,currentLevel:currentLevel,conditionValues:new Array()[currentLevelValue]};
		pramObj[0]=dh;
	}else{
		var find = false;
		for(var i=0;i<paramObj.length;i++){
			var dh = paramObj[i]; 
			if(dh.name==dhName){
				find = true;
				dh.currentLevel = currentLevel;
				if(currentLevelValue && currentLevelValue!=null){
					dh.conditionValues[currentLevel-1] = currentLevelValue;
					if(currentLevel<dh.conditionValues.length-1){
						dh.conditionValues.splice(currentLevel, dh.conditionValues.length-currentLevel);
					}
				}else{
					if(currentLevel<=dh.conditionValues.length-1){
						dh.conditionValues.splice(currentLevel, dh.conditionValues.length-currentLevel);
					}
				}
			}
		}
		if(!find){
			paramObj.push({name:dhName,currentLevel:currentLevel,conditionValues:[currentLevelValue]});
		}
	}
	var json = JSON.stringify({olapcontext:paramObj});
	param.value = json;
	var form = document.getElementsByName('resultForm')[0];
	form.target='_self';
	form.action='Report-ResultAction.'+window.action_suffix;
	document.getElementsByName('cachedId')[0].value='';
	document.getElementsByName('newReport')[0].value='true';
	document.getElementsByName('nPage')[0].value='1';
	document.getElementsByName('pageCount')[0].value='0';
	
	// 支持导航条start  fuyw
	if (typeof urNavLevels != "undefined") {
		if (typeof currentLevelValue == "undefined") {
			// 回退，不能简单地使用history.go(-1)，因为还有数据需要传递，form.submit()必须要执行
			// 导航条回退
			urNavLevels.pop();
			urNavLevels.pop();
			// 因为每次点击“上卷”按钮时，不是回退，而是前进一步，所以回退时需要增加两步
			if (urNavLevels.length) {
				var lastLevel = urNavLevels.pop();
		  		var result = getNavStepFromLevel(lastLevel);
				var rName = result.name;
				var step = result.step;
				lastLevel = rName + ';' + (step + 2);
				urNavLevels.push(lastLevel);
			}
		} else {
			// urNavLevels的长度至少为1（包含当前报表名）
			// 由于访问的是Report-ResultAction.do，回退时只退1步
			urNavLevels[urNavLevels.length - 1] += ';1';
		}
//		form.action += "?ur_nav_levels=" + encodeto64(JSON.stringify(urNavLevels));
		if (!form.elements['ur_nav_levels']) {
			var levelsElement = document.createElement("input");
			levelsElement.type = 'hidden';
			levelsElement.name = 'ur_nav_levels';
			levelsElement.value = encodeto64(JSON.stringify(urNavLevels));
			form.appendChild(levelsElement);
		}
	}
	// 支持导航条end
	
	form.submit();
}

function drillThrough(reportId,conditions){
	var formId = 'drillThroughForm';
	var contextId = 'drillThroughContext';
	var rid = 'reportId';
	var encode = 'encode';
	var form = document.getElementById(formId);
	var contextElement = document.getElementById(contextId);
	var ridElement = document.getElementById(rid);
	var encodeElement = document.getElementById(encode);
	if(form==null || form=='undefined'){
	var form = document.createElement("form");
		form.id = formId;
		//这里使用了一个unieap的全局变量
		form.action =WEB_APP_NAME+ "/Report-ResultAction."+window.action_suffix;
		form.method = 'post';
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(form);
		
		contextElement = document.createElement("input");
		contextElement.type='hidden';
		contextElement.id=contextId;
		contextElement.name=contextId;
		form.appendChild(contextElement);
		
		ridElement = document.createElement("input");
		ridElement.type='hidden';
		ridElement.id=rid;
		ridElement.name=rid;
		form.appendChild(ridElement);
		
		encodeElement = document.createElement("input");
		encodeElement.type='hidden';
		encodeElement.id=encode;
		encodeElement.name=encode;
		form.appendChild(encodeElement);
	}
	ridElement.value=reportId;
	contextElement.value=conditions;
	encodeElement.value='true';
	form.target='_self';
	
	// 支持导航条start  fuyw
	if (typeof urNavLevels != "undefined") {
		// urNavLevels的长度至少为1（包含当前报表名）
		// 由于访问的是Report-ResultAction.do，回退时只退1步
		urNavLevels[urNavLevels.length - 1] += ';1';
//		form.action += "?ur_nav_levels=" + encodeto64(JSON.stringify(urNavLevels));
		if (!form.elements['ur_nav_levels']) {
			var levelsElement = document.createElement("input");
			levelsElement.type = 'hidden';
			levelsElement.name = 'ur_nav_levels';
			levelsElement.value = encodeto64(JSON.stringify(urNavLevels));
			form.appendChild(levelsElement);
		}
	}
	// 支持导航条end
	
	form.submit();
}
//以下为增加键盘翻页操作，如果不需要该特性可以将其删除。
NeuReport.addOnLoad(
	function(){
		var nextpage = document.getElementById('nextpage');
		if(nextpage){
			var body = document.getElementsByTagName('body')[0];
			body.onkeydown=keydown;
			window.focus();
			body.focus();
		}
	}
);

function keydown(){
	var resultForm = document.getElementsByName('resultForm')[0];
	var e = (typeof event!='undefined')?event:arguments[0];
	var code = e.keyCode;
	if(code==39||code==40){
		var nextpage = document.getElementById('nextpage');
		if(nextpage){
			var command = nextpage.getAttribute('onclick');
			eval(command);
		}
	}else if(code==37||code==38){
	    var prepage = document.getElementById('lastpage');
	    if(prepage){
			var command = prepage.getAttribute('onclick');
			eval(command);
	    }
	}
}
function backButton(){
	var changePageCount = document.getElementsByName("changePageCount")[0].value;
	var count = -Number(changePageCount);
	history.go(count);
}

function graphOpenReport(url, target) {
	// url一定是访问Report-Guage.do的
	// 创建临时form，用来实现页面跳转
	var form = document.createElement('form');
	form.style.display = 'none';
	form.method = 'POST';
	form.target = target;
	form.action = url;
	if (typeof urNavLevels != "undefined") {
		if (target == '_self' || target == '_parent' || target == '_top') {
			form.action += "&ur_nav_levels=" + encodeto64(JSON.stringify(urNavLevels));
		}
	}
	document.body.appendChild(form);
	form.submit();
	document.body.removeChild(form);
}

function chartOpenReport(url,target){
	// url一定是访问Report-Guage.do的
	// 创建临时form，用来实现页面跳转
	var form = document.createElement('form');
	form.style.display = 'none';
	form.method = 'POST';
	form.target = target;
	form.action = url;
	if (typeof urNavLevels != "undefined") {
		if (target == '_self' || target == '_parent' || target == '_top') {
			form.action += "&ur_nav_levels="+ encodeto64(JSON.stringify(urNavLevels)).replace(/\+/g, '-').replace(/\//g, '_');
		}
	}
	document.body.appendChild(form);
	form.submit();
	document.body.removeChild(form);	
}

function getNavStepFromLevel(level) {
	var name, step;
	if (level.indexOf(';') > 0) {
		name = level.substr(0, level.indexOf(';'));
		step = parseInt(level.substr(level.indexOf(';') + 1));
	} else {
		name = level;
		step = 2;
	}
	return {name: name, step: step};
}

function expandAll(){
	jQuery('#dataTable').treetable('expandAll'); return false;
}

function collapseAll(){
	jQuery('#dataTable').treetable('collapseAll'); return false;
}

function doHyperLink(data, reportId, cellType, e, value){
	if (reportId == null || typeof reportId == "undefined"){		
		reportId = document.getElementById('reportId').value;
	}
	if (data.length > 1){
		var linkContent = '';		
		for (var index in data){
			linkContent += '<script type="text/javascript">var data' + index + '=[]; var temp'+ index + '=' + JSON.stringify(data[index]) + 
			';data' + index + '.push(temp' + index + ');var reportId' +index +'="' + reportId+'";var cellType' + index +
			'=' + cellType +';var e' + index +'=' + JSON.stringify(e) + ';var value' + index +'=' + JSON.stringify(value);
			if (data[index].type == 0){
				linkContent += ';</script><div class="linkclass" onClick="linkReport(data' + index + ', reportId' + 
				index +', cellType' + index +', e' + index +', value' + index +')">'+data[index].name +'</div>';
			} else if (data[index].type == 1){
				linkContent += ';</script><div class="linkclass" onClick="linkUrl(data' + index + ', reportId' + 
				index +', cellType' + index +', e' + index +', value' + index +')">'+data[index].name +'</div>';
			} else if (data[index].type == 2){
				linkContent += ';</script><div class="linkclass" onClick="linkJavaScript(data' + index + ', reportId' + 
				index +', cellType' + index +', e' + index +', value' + index +')">'+data[index].name +'</div>';
			} else if (data[index].type == 4){
				linkContent += ';</script><div class="linkclass" onClick="linkReportFormula(data' + index + ', cellType' +
				index +', e' + index +', value' + index +')">'+data[index].name +'</div>';
			} else {
				linkContent += ';</script><div class="linkclass" onClick="linkChart(data' + index + ', reportId' + 
				index +', cellType' + index +', e' + index +', value' + index +')">'+data[index].name +'</div>';
			}
		}
		
		layer.open({
			type: 1,
			title: false,
			closeBtn: 0,
		    area: ['150px', 30*data.length + 'px'],
		    shadeClose: true, //点击遮罩关闭
		    content: linkContent
		});
	} else {
		if (data[0].type == 0){
			linkReport(data, reportId, cellType, e, value);
		} else if (data[0].type == 1){			
			linkUrl(data, reportId, cellType, e, value);
		} else if (data[0].type == 2) {
			linkJavaScript(data, reportId, cellType, e, value);
		} else if (data[0].type == 4) {
			linkReportFormula(data, cellType, e, value);
		} else {
			linkChart(data, reportId, cellType, e, value);
		}
	}
}
	
	function linkReport(data, reportId, cellType, e, value){
		layer.close(layer.index);
		
		var url = charts_server + "/Report-Guage." + action_suffix + "?reportId=" + data[0].reportId;
		if (cellType != 8){
			for (var index in data[0].parameterData){
				url += "&" + data[0].parameterData[index].name + "=" + encodeto64(data[0].parameterData[index].value);
			}
			url += "&encode=true";
			if (data[0].popFrame != "_blank"){
				 url += "&ur_nav_levels=" + encodeto64(JSON.stringify(urNavLevels)).replace(/\+/g, '-').replace(/\//g, '_');
			}
		
			var a = document.createElement('a');
			a.setAttribute('href', url);
			a.setAttribute('target', data[0].popFrame);
			a.setAttribute('id', 'jsFora');
			//防止反复添加
			if(document.getElementById('jsFora')) {
			 	document.body.removeChild(document.getElementById('jsFora'));
			}
			document.body.appendChild(a);
			a.click();
		} else {
			var param = "{";
			var jsFunction = "";
			url += "&encode=true";
			
			for (var index in data[0].parameterData){
				param += "'" + data[0].parameterData[index].name + "':'" + data[0].parameterData[index].value + "',";
			}
			param += "'target':'" + data[0].popFrame + "'}";
			jsFunction += "var url='" + url + "';var param=" + param + ";chartOpenReportNavNew(url,param,e,value);";
			eval(jsFunction);
		}
	}
	
	function linkReportFormula(data, cellType, e, value){
		layer.close(layer.index);
		
		var url = data[0].content;
		if (cellType != 8){
			if (data[0].popFrame != "_blank"){
				url += "&ur_nav_levels=" + encodeto64(JSON.stringify(urNavLevels)).replace(/\+/g, '-').replace(/\//g, '_');
			}
		
			var a = document.createElement('a');
			a.setAttribute('href', url);
			a.setAttribute('target', data[0].popFrame);
			a.setAttribute('id', 'jsFora');
			//防止反复添加
			if(document.getElementById('jsFora')) {
			 	document.body.removeChild(document.getElementById('jsFora'));
			}
			document.body.appendChild(a);
			a.click();
		} else {
			var jsFunction = "";
			if(url.indexOf('chartOpenReportNavNew') != -1){
				jsFunction += url.substring(0,url.indexOf('chartOpenReportNavNew'));
				jsFunction += "chartData.target='" + data[0].popFrame + "';" + 
				url.substring(url.indexOf('chartOpenReportNavNew'));
			}
			eval(jsFunction);
		}
	}
	
	function linkUrl(data, reportId, cellType, e, value){
		layer.close(layer.index);
		
		var url = data[0].url + "?";
		for (var index in data[0].parameterData){
			var pv = data[0].parameterData[index].value;
			var pn = data[0].parameterData[index].name;
			if (cellType == 8 && data[0].parameterData[index].nam != "reportId" && data[0].parameterData[index].nam != "target" && isfunction(pv)){
				url += pn + "=" + value[pv.substring(pv.indexOf("(")+1,pv.indexOf(")"))]  + "&";	
			} else {
				url += pn + "=" + pv + "&";
			}
		}
		
		url = url.substring(0, url.length - 1);
		var a = document.createElement('a');
		a.setAttribute('href', url);
	    a.setAttribute('target', data[0].popFrame);
	    a.setAttribute('id', 'jsFora');
	    //防止反复添加
	    if(document.getElementById('jsFora')) {
	    	document.body.removeChild(document.getElementById('jsFora'));
	    }
	    document.body.appendChild(a);
	    a.click();
	}
	
	function linkJavaScript(data, reportId, cellType, e, value){
		layer.close(layer.index);
		
		var hasParameter = false;
		if (data[0].jsType == "1"){
			var jsFunction = data[0].jsFunction;
//			var parameterName = data[0].jsFunction.substring(data[0].jsFunction.indexOf("(") + 1,data[0].jsFunction.indexOf(")"));
//			var nameArr = parameterName.split(",");
//			var jsFunction = data[0].jsFunction.substring(0,data[0].jsFunction.indexOf("(")+1);
//			for (var i = 0; i < nameArr.length; i++){
//				for (var index in data[0].parameterData){
//					var pv = data[0].parameterData[index].value;
//					var pn = data[0].parameterData[index].name;
//					if (pn == nameArr[i]){
//						if (cellType == 8 && isfunction(pv)) {
//							jsFunction += "'" + value[pv.substring(pv.indexOf("(")+1,pv.indexOf(")"))] + "',";
//						} else {
//							jsFunction += "'" + pv + "',";
//						}
//						break;
//					}
//					hasParameter = true;
//				}
//			}
//			
//			if (hasParameter) {
//				jsFunction = jsFunction.substring(0, jsFunction.length - 1);
//			}
//			jsFunction += ")";
			eval(jsFunction);
		} else {
			var jsFunction = "";
			for (var index in data[0].parameterData){
				var pv = data[0].parameterData[index].value;
				var pn = data[0].parameterData[index].name;
				if (cellType == 8 && isfunction(pv)) {
					jsFunction += "var "+ pn + "='" + value[pv.substring(pv.indexOf("(")+1,pv.indexOf(")"))] + "';";		
				} else {
					jsFunction += "var "+ pn + "='" + pv + "';";
				}
			}
			jsFunction += data[0].jsFunctionBody;
			eval(jsFunction);
		}
	}
	
	function linkChart(data, reportId, cellType, e, value){
		layer.close(layer.index);
		
		for (var index in data[0].linkCharts){
			var jsFunction = "";
			var url = charts_server + "/Report-ChartLink." + action_suffix + "?";
			var param = "{'reportId':'" + reportId + "','chartId':'" + data[0].linkCharts[index].col + data[0].linkCharts[index].row + "',";
			var hasParameter = false;
			for (var i in data[0].linkCharts[index].parameterData){
				param += "'" + data[0].linkCharts[index].parameterData[i].name + "':'" +  data[0].linkCharts[index].parameterData[i].value + "',"
				hasParameter = true;
			}
			if (hasParameter){
				param = param.substring(0, param.length - 1);
			}
			param += "}";
			if (cellType == 8){
				jsFunction += "var url='" + url + "';var param=" + param + ";chartLinkReportNew(url,param,e,value);";
			} else {
				jsFunction += "var url='" + url + "';var param=" + param + ";chartLinkReportNew(url,param);";
			}
			eval(jsFunction);
		}
	}
